<?php
/**
 * Zend Framework

 *
 * LICENSE
 *
 */


/**
 * @see uc_client
 */



/**
 * @category   Zend
 * @package    Zend_Auth
 * @subpackage Adapter
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Ext_User_Action_Gain_Adapter
{
    /**
     * Digest authentication user
     *
     * @var string
     */
    private $_adapter;

    /**
     * Sets adapter options
     *
     * @param  mixed $username
     * @param  mixed $password
     * @return void
     */
    public function __construct($userId)
    {
    	if(!isset($this->_adapter))
    	{
    		$front = Zend_Controller_Front::getInstance();
			$bootstrap = $front->getParam('bootstrap');
			$options = $bootstrap->getApplication()->getOptions();

			$classname = "Ext_User_Action_Gain_Adapter_".ucfirst($options['auth']['adapter']['base']);
			if(!class_exists( $classname ))
	    	{
	    		require_once 'Ext/User/Action/Gain/Exception.php';
	          	throw new Ext_User_Action_Gain_Exception("Gain adapter '".$classname."' is not exists.");
	    	}
	    	
	    	$this->_adapter = new $classname($userId);
    	}
    }
    
    public function getAdapter()
    {
		return $this->_adapter;
    }
}
